package com.example.ordersystem.controller;

import com.example.ordersystem.entity.Admin;
import com.example.ordersystem.entity.vo.ResultMessage;
import com.example.ordersystem.service.AdminService;
import com.example.ordersystem.util.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("order/admin")
public class AdminController {

    @Autowired
    AdminService adminService;

    @Autowired
    ResultUtil resultUtil;

    @PostMapping("login")
    public ResultMessage login(@RequestBody Admin admin)
    {
         if(adminService.login(admin))
         {
             return resultUtil.success("登录成功");
         }
         return resultUtil.error("用户名或密码错误");
    }
}
